﻿using Microsoft.Xna.Framework.Graphics;

using Storyteller.Framework.Math;

namespace Storyteller.Framework.Graphics
{
	public class SpriteShader
	{
		internal Effect Effect { get { return effect; } }

		public SpriteShader(Effect effect)
		{
			this.effect = effect;

			viewMatrix = Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.UnitY);
		}

		public Matrix4 GetWorldMatrix(int screenWidth, int screenHeight)
		{
			if (screenWidth != width || screenHeight != height)
			{
				width = screenWidth;
				height = screenHeight;

				projectionMatrix = Matrix4.CreateOrthographicOffCenter(0, width, height, 0, 1, 1000);

				worldMatrix = modelMatrix * viewMatrix * projectionMatrix;
			}

			return worldMatrix;
		}

		Effect effect;

		Matrix4 projectionMatrix = Matrix4.Identity;
		Matrix4 viewMatrix = Matrix4.Identity;
		Matrix4 modelMatrix = Matrix4.Identity;
		Matrix4 worldMatrix;

		int width = 0, height = 0;
	}
}
